<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f"%>
<%@ taglib uri="/WEB-INF/tld/tag.tld" prefix="my"%>
<%@ taglib uri="/WEB-INF/tld/mobai-el-common.tld" prefix="el"%>
<!DOCTYPE html>
<html>
<head>
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet" type="text/css"
	href="/three/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css"
	href="/three/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css"
	href="/three/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css"
	href="/three/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css"
	href="/three/static/h-ui.admin/css/style.css" />
<title>分类列表</title>
</head>
<body>
	<div class="page-container">
		<form action="/three/bnt/type" method="post" id="form1">
			<div class="cl pd-5 bg-1 bk-gray mt-20">
				<span class="l"> <a style="text-decoration: none"
					class="btn btn-primary radius ml-5" onClick="type_add()"
					href="javascript:;"><i class="Hui-iconfont">&#xe600;</i>添加分类</a> <span
					style="margin-left: 660px"> <input type="text"
						name="typeName" value="${typeName }" placeholder="请输入分类名称"
						style="width: 250px" class="input-text">
						<button class="btn btn-success" type="submit">
							<i class="Hui-iconfont">&#xe665;</i> 查询
						</button>
				</span>
				</span>
			</div>

			<div class="mt-20">
				<table
					class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
					<thead>
						<tr class="text-c">
							<th>分类名称</th>
							<th>备注</th>
							<th>更新时间</th>
							<th>排序号</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${bisNurseTypeList }" var="typeList">
							<tr class="text-c">
								<td>${typeList.typeName }</td>
								<td>${typeList.typeRemark }</td>
								<td><f:formatDate
										value="${typeList.modifyTime==null?typeList.createTime:typeList.modifyTime }"
										pattern="yyyy-MM-dd" /></td>
								<td>${typeList.sortNo }</td>
								<td class="f-14 td-manage"><a style="text-decoration: none"
									class="ml-5"
									onClick='type_edit(${el:toJsonString(typeList)})' title="编辑"
									href="javascript:;"><i class="Hui-iconfont">&#xe6df;</i></a> 
									<a style="text-decoration: none" class="ml-5"
									onClick="type_del('${typeList.typeId}')" href="javascript:;"
									title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
			</div>
		</form>
		<!-----------------------------显示所有结束------------------------------------------------------->

		<!------ ----------------------添加 修改分类信息模态框开始---------------------------------------------------- -->
		<div id="modal-demo" class="modal fade" tabindex="-1" role="dialog"
			aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content radius" id="radius">
					<div class="modal-header">
						<h3 class="modal-title">编辑分类信息</h3>
						<a class="close" data-dismiss="modal" aria-hidden="true"
							href="javascript:void();">×</a>
					</div>
					<div class="modal-body">
						<!------ ----------------------模态框内容部分开始---------------------------------------------------- -->
						<form class="form form-horizontal" id="form2"
							action="" method="post">
							<input type="hidden" name="typeId" id="typeid">
							<table>
								<tr>
									<td>
										<div class="row cl">
											<label class="form-label col-xs-4 col-sm-3"><font color="red">*</font>分类名称：</label>
											<div class="formControls col-xs-6 col-sm-6">
												<input type="text" class="input-text" name="typeName">
											</div>
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="row cl">
											<label class="form-label col-xs-4 col-sm-3">排序号：</label>
											<div class="formControls col-xs-6 col-sm-6">
												<input type="text" class="input-text" name="sortNo" placeholder="0-9的整数">
											</div>
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="row cl">
											<label class="form-label col-xs-4 col-sm-3">备注：</label>
											<div class="formControls col-xs-6 col-sm-6">
												<textarea class="textarea radius" style="white: 100px"
													rows="10" cols="100" name="typeRemark"></textarea>
											</div>
										</div>
									</td>
								</tr>
							</table>
						</form>
						<!------ ----------------------模态框内容部分结束---------------------------------------------------- -->
					</div>
					<div class="modal-footer">
						<button class="btn btn-secondary radius" type="button" id="but" onclick="dj()">
							<i class="Hui-iconfont">&#xe632;</i> 保存
						</button>
						<button class="btn btn-default radius" data-dismiss="modal"
							aria-hidden="true" id="guanbi">关闭</button>
					</div>
				</div>
			</div>
		</div>
		<!-- 添加 修改分类信息模态框结束--------------------------------------------------- -->
	</div>

	<script type="text/javascript"
		src="/three/lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="/three/static/formEdit.js"></script>
	<script type="text/javascript" src="/three/lib/layer/2.4/layer.js"></script>
	<script type="text/javascript" src="/three/static/h-ui/js/H-ui.min.js"></script>
	<script type="text/javascript"
		src="/three/static/h-ui.admin/js/H-ui.admin.js"></script>
	<!--/_footer 作为公共模版分离出去-->

	<!--请在下方写此页面业务相关的脚本-->
	<script type="text/javascript"
		src="/three/lib/My97DatePicker/4.8/WdatePicker.js"></script>
	<script type="text/javascript"
		src="/three/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
	<script type="text/javascript" src="/three/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="/three/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="/three/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="/three/lib/jquery.validation/1.14.0/messages_zh.js"></script>
	<script type="text/javascript">
/*分类-排序*/
$('.table-sort').dataTable({
	"aaSorting": [[ 1, "desc" ]],//默认第几个排序
	"bStateSave": true,//状态保存
	"pading":false,
	"aoColumnDefs": [
	  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
	  {"orderable":false,"aTargets":[1,4]}// 不参与排序的列
	]
});

/*分类-刷新模态框*/
$('#modal-demo').on('hidden.bs.modal', function () {
	window.location.reload();
});

/*分类-添加*/
function type_add(){
	$("#modal-demo").modal("show");
}

/*分类-修改*/
function type_edit(typeList){
	console.log(typeList);
	$("#modal-demo").modal("show");
	$("#form2").formEdit(typeList);
}

/*分类-删除*/
function type_del(typeId){
	layer.confirm('确认要删除吗？',function(index){
		$("#form1").attr("action","/three/bnt/type_del?typeId="+typeId);
		$("#form1").submit();
		layer.msg('已删除!',{icon:1,time:1000});
				
	});
}

/*分类-添加++修改*/
function dj(){
	console.log($("#typeid").val()+">>>");
	if($("#typeid").val()==null||$("#typeid").val()==""){
		console.log("添加");
		$("#form2").attr("action","/three/bnt/type_add");
		$("#form2").submit();
	}else{
		console.log("修改");
		$("#form2").attr("action","/three/bnt/type_update");
		$("#form2").submit();
	} 
}

//表单验证
$("#form2").validate({
	rules:{
		typeName:{
			required:true,
		},
		sortNo:{
			digits:true,
		},
	},
	onkeyup:false,
	focusCleanup:true,
});
</script>
</body>
</html>